<?php include ("../smarty/libs/Smarty.class.php");

include ("../includes/common.php");
init(); 
$func_ary=array("wholesale","retail");

if(fe($_REQUEST[Type]))
{
	$_REQUEST[Type]();
	die();
}
else if(($_REQUEST[cat])){
		items(($_REQUEST[cat]));
		die();
}
else if(($_REQUEST[item])){
	each_item(($_REQUEST[item]));
	die();
}
else if(($_REQUEST[Type]=='home')){
	home();
	die();
}
else{
	index();
}

function each_item($val){
	$smarty = new Smarty;
	$smarty->assign("itemvar",$val);
	$areas= get_row_con_info("areas","","","","0");
	$smarty->assign("areas",$areas);
	$items= get_row_con_info("items","","","","0");
	$smarty->assign("items",$items);
	$categories= get_row_con_info("category","","","","0");
	$smarty->assign("shop",$categories);
	$companies= get_row_con_info("company","","","","0");
	$smarty->assign("companyList",$companies);
	$wholeitems= get_row_con_info("wholesale","","","","0");
	$smarty->assign("wholesaleList",$wholeitems);
	$smarty->assign("cookieValDisp",$_GET['cook1']);
	$smarty->display('displayItem.tpl');
	die();
}

function items($i){
	$smarty = new Smarty;
	$smarty->assign('catvar',$i);
	$areas= get_row_con_info("areas","","","","0");
	$smarty->assign("areas",$areas);
	$items= get_row_con_info("items","","","","0");
	$smarty->assign("items",$items);
	$categories= get_row_con_info("category","","","","0");
	$smarty->assign("shop",$categories);
	$companies= get_row_con_info("company","","","","0");
	$smarty->assign("companyList",$companies);
	$wholeitems= get_row_con_info("wholesale","","","","0");
	$smarty->assign("wholesaleList",$wholeitems);
	$smarty->assign("cookieValDisp",$_GET['cook']);
	$smarty->display('items.tpl');
	die();
}


function wholesale(){
	$smarty=new Smarty();
	//setcookie("flow","wholesale");
	//To set the wholesale in cookie
	$cookie_name = "flow";
	$cookie_value = $_REQUEST[Type];
	setcookie($cookie_name, $cookie_value);
	$cookie=$_COOKIE[$cookie_name];
	$smarty->assign("cookieVal",$cookie);
	$categories= get_row_con_info("category","","","","0");
	$smarty->assign("shop",$categories);
	$areas= get_row_con_info("areas","","","","0");
	$smarty->assign("areas",$areas);
	$smarty->display('shops.tpl');
	die();
}

function retail(){
	$smarty=new Smarty();
	$categories= get_row_con_info("category","","","","0");
	$smarty->assign("shop",$categories);
	$areas= get_row_con_info("areas","","","","0");
	$smarty->assign("areas",$areas);
	$smarty->display('shops.tpl');
	die();
}

function index(){
	$smarty = new Smarty;
	$areas= get_row_con_info("areas","","","","0");
	$smarty->assign("areas",$areas);
  
	$smarty->display('index.tpl');
	die();
}

function home(){
	$smarty = new Smarty;
	$areas= get_row_con_info("areas","","","","0");
	$smarty->assign("areas",$areas);
	$smarty->display('home.tpl');
	die();
}	

?>

